package com.yc.ServerClient;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class Test3_Client {
    //Test3的客户端程序
    public static void main(String[] args) throws IOException {
//                                    telnet 192.168.16.222 10001    8.130.104.127 12345
        Socket s=new Socket("localhost",10001);
        System.out.println("联接成功！"+s);

        //用输入流来接时间
        try(InputStream iis=s.getInputStream()){
            byte[] bs=new byte[1024];
            int length=-1;
            System.out.println("客户端等待服务端的响应");
            while (  (length=iis.read(bs,0,bs.length))!=-1  ){
                String str=new String(bs,0,length);
                System.out.println("服务端的响应"+str);
            }
        }catch (Exception ex){
            ex.printStackTrace();
        }
        System.out.println("客户端断开与服务端的联接");
        s.close();
    }
}
